import { getToken, removeToken } from '@/utils/auth';
import { createRouter, createWebHistory, onBeforeRouteLeave } from 'vue-router'
import routes from './routers'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

router.beforeEach((to, from, next) => {
  if (!to.meta.isAuthenticated && !getToken()) {
    next("/logins");
    return
  }
  next();
  // removeToken()
})


export default router
